package meng.spring.test19.springaopapi;

import java.lang.reflect.Method;

import org.springframework.aop.ThrowsAdvice;

/**
 * 异常通知
 * 
 * 1.如果连接点发生异常， ThrowsAdvice在连接点返回后被调用
 * 
 * 2.如果ThrowsAdvice发生异常，那它将覆盖原有异常
 * 
 * 3.接口org.springframework.aop.ThrowsAdvice不包含任何方法，仅仅是一个声明 实现类需要实现类似下面的方法：
 * 
 * void afterThrowing(Exception ex) throws Throwable
 * 
 * void afterThrowing(RemoteException ex) throws Throwable
 * 
 * void afterThrowing(Method method, Object[] args, Object target, Exception ex)
 * throws Throwable
 * 
 * void afterThrowing(Method method, Object[] args, Object target, ServletException ex)
 * throws Throwable
 * 
 * @author mengzhang6
 *
 */
public class MyThrowsAdvice implements ThrowsAdvice {

	public void afterThrowing(Exception ex) throws Throwable {
		System.out.println("MyThrowsAdvice - afterThrowing");
	}

	public void afterThrowing(Method method, Object[] args, Object target,
			Exception ex) throws Throwable {
		System.out.println("MyThrowsAdvice - afterThrowing 2");
		System.out.println("MyThrowsAdvice-" + target.getClass().getName());
		System.out.println("MyThrowsAdvice-" + method.getName());
		System.out.println("MyThrowsAdvice-" + args);
	}

}
